import { $http } from '@/utils';
import { $ResponseCode } from '@/utils/const/env';
export const Realname={
    upload(data: any) {
        return new Promise((resolve, reject) => {
            if(!data.name){
                data.name = 'file';
            }
            $http.upload('Realname/upload', data).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch((err:any) => {
                console.log(err);
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    submit(data: any) {
        return new Promise((resolve, reject) => {
            $http.post('Realname/submit', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res)
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' })
            })
        })
    },
    info() {
        return new Promise((resolve, reject) => {
            $http.get('Realname/info').then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject(res)
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' })
            })
        })
    }
}